home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / info / lispref.info-34 < prev    next >
Encoding:
GNU Info File  |  1995-09-01  |  46.2 KB  |  1,147 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo-1.63
  2. from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995
  12.  
  13.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  14. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  15. Copyright (C) 1995 Amdahl Corporation.  Copyright (C) 1995 Ben Wing.
  16.  
  17.    Permission is granted to make and distribute verbatim copies of this
  18. manual provided the copyright notice and this permission notice are
  19. preserved on all copies.
  20.  
  21.    Permission is granted to copy and distribute modified versions of
  22. this manual under the conditions for verbatim copying, provided that the
  23. entire resulting derived work is distributed under the terms of a
  24. permission notice identical to this one.
  25.  
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that this permission notice may be stated in a
  29. translation approved by the Foundation.
  30.  
  31.    Permission is granted to copy and distribute modified versions of
  32. this manual under the conditions for verbatim copying, provided also
  33. that the section entitled "GNU General Public License" is included
  34. exactly as in the original, and provided that the entire resulting
  35. derived work is distributed under the terms of a permission notice
  36. identical to this one.
  37.  
  38.    Permission is granted to copy and distribute translations of this
  39. manual into another language, under the above conditions for modified
  40. versions, except that the section entitled "GNU General Public License"
  41. may be included in a translation approved by the Free Software
  42. Foundation instead of in the original English.
  43.  
  44. 
  45. File: lispref.info,  Node: Filter Functions,  Next: Accepting Output,  Prev: Process Buffers,  Up: Output from Processes
  46.  
  47. Process Filter Functions
  48. ------------------------
  49.  
  50.    A process "filter function" is a function that receives the standard
  51. output from the associated process.  If a process has a filter, then
  52. *all* output from that process is passed to the filter.  The process
  53. buffer is used directly for output from the process only when there is
  54. no filter.
  55.  
  56.    A filter function must accept two arguments: the associated process
  57. and a string, which is the output.  The function is then free to do
  58. whatever it chooses with the output.
  59.  
  60.    A filter function runs only while XEmacs is waiting (e.g., for
  61. terminal input, or for time to elapse, or for process output).  This
  62. avoids the timing errors that could result from running filters at
  63. random places in the middle of other Lisp programs.  You may explicitly
  64. cause Emacs to wait, so that filter functions will run, by calling
  65. `sit-for' or `sleep-for' (*note Waiting::.), or `accept-process-output'
  66. (*note Accepting Output::.).  Emacs is also waiting when the command
  67. loop is reading input.
  68.  
  69.    Quitting is normally inhibited within a filter function--otherwise,
  70. the effect of typing `C-g' at command level or to quit a user command
  71. would be unpredictable.  If you want to permit quitting inside a filter
  72. function, bind `inhibit-quit' to `nil'.  *Note Quitting::.
  73.  
  74.    If an error happens during execution of a filter function, it is
  75. caught automatically, so that it doesn't stop the execution of whatever
  76. program was running when the filter function was started.  However, if
  77. `debug-on-error' is non-`nil', the error-catching is turned off.  This
  78. makes it possible to use the Lisp debugger to debug the filter
  79. function.  *Note Debugger::.
  80.  
  81.    Many filter functions sometimes or always insert the text in the
  82. process's buffer, mimicking the actions of XEmacs when there is no
  83. filter.  Such filter functions need to use `set-buffer' in order to be
  84. sure to insert in that buffer.  To avoid setting the current buffer
  85. semipermanently, these filter functions must use `unwind-protect' to
  86. make sure to restore the previous current buffer.  They should also
  87. update the process marker, and in some cases update the value of point.
  88. Here is how to do these things:
  89.  
  90.      (defun ordinary-insertion-filter (proc string)
  91.        (let ((old-buffer (current-buffer)))
  92.          (unwind-protect
  93.              (let (moving)
  94.                (set-buffer (process-buffer proc))
  95.                (setq moving (= (point) (process-mark proc)))
  96.  
  97.      (save-excursion
  98.                  ;; Insert the text, moving the process-marker.
  99.                  (goto-char (process-mark proc))
  100.                  (insert string)
  101.                  (set-marker (process-mark proc) (point)))
  102.                (if moving (goto-char (process-mark proc))))
  103.            (set-buffer old-buffer))))
  104.  
  105. The reason to use an explicit `unwind-protect' rather than letting
  106. `save-excursion' restore the current buffer is so as to preserve the
  107. change in point made by `goto-char'.
  108.  
  109.    To make the filter force the process buffer to be visible whenever
  110. new text arrives, insert the following line just before the
  111. `unwind-protect':
  112.  
  113.      (display-buffer (process-buffer proc))
  114.  
  115.    To force point to move to the end of the new output no matter where
  116. it was previously, eliminate the variable `moving' and call `goto-char'
  117. unconditionally.
  118.  
  119.    In earlier Emacs versions, every filter function that did regexp
  120. searching or matching had to explicitly save and restore the match data.
  121. Now Emacs does this automatically; filter functions never need to do it
  122. explicitly.  *Note Match Data::.
  123.  
  124.    A filter function that writes the output into the buffer of the
  125. process should check whether the buffer is still alive.  If it tries to
  126. insert into a dead buffer, it will get an error.  If the buffer is dead,
  127. `(buffer-name (process-buffer PROCESS))' returns `nil'.
  128.  
  129.    The output to the function may come in chunks of any size.  A program
  130. that produces the same output twice in a row may send it as one batch
  131. of 200 characters one time, and five batches of 40 characters the next.
  132.  
  133.  - Function: set-process-filter PROCESS FILTER
  134.      This function gives PROCESS the filter function FILTER.  If FILTER
  135.      is `nil', then the process will have no filter.  If FILTER is `t',
  136.      then no output from the process will be accepted until the filter
  137.      is changed. (Output received during this time is not discarded,
  138.      but is queued, and will be processed as soon as the filter is
  139.      changed.)
  140.  
  141.  - Function: process-filter PROCESS
  142.      This function returns the filter function of PROCESS, or `nil' if
  143.      it has none.  `t' means that output processing has been stopped.
  144.  
  145.    Here is an example of use of a filter function:
  146.  
  147.      (defun keep-output (process output)
  148.         (setq kept (cons output kept)))
  149.           => keep-output
  150.  
  151.      (setq kept nil)
  152.           => nil
  153.  
  154.      (set-process-filter (get-process "shell") 'keep-output)
  155.           => keep-output
  156.  
  157.      (process-send-string "shell" "ls ~/other\n")
  158.           => nil
  159.      kept
  160.           => ("lewis@slug[8] % "
  161.  
  162.      "FINAL-W87-SHORT.MSS    backup.otl              kolstad.mss~
  163.      address.txt             backup.psf              kolstad.psf
  164.      backup.bib~             david.mss               resume-Dec-86.mss~
  165.      backup.err              david.psf               resume-Dec.psf
  166.      backup.mss              dland                   syllabus.mss
  167.      "
  168.      "#backups.mss#          backup.mss~             kolstad.mss
  169.      ")
  170.  
  171. 
  172. File: lispref.info,  Node: Accepting Output,  Prev: Filter Functions,  Up: Output from Processes
  173.  
  174. Accepting Output from Processes
  175. -------------------------------
  176.  
  177.    Output from asynchronous subprocesses normally arrives only while
  178. XEmacs is waiting for some sort of external event, such as elapsed time
  179. or terminal input.  Occasionally it is useful in a Lisp program to
  180. explicitly permit output to arrive at a specific point, or even to wait
  181. until output arrives from a process.
  182.  
  183.  - Function: accept-process-output &optional PROCESS SECONDS MILLISEC
  184.      This function allows XEmacs to read pending output from processes.
  185.      The output is inserted in the associated buffers or given to
  186.      their filter functions.  If PROCESS is non-`nil' then this
  187.      function does not return until some output has been received from
  188.      PROCESS.
  189.  
  190.      The arguments SECONDS and MILLISEC let you specify timeout
  191.      periods.  The former specifies a period measured in seconds and the
  192.      latter specifies one measured in milliseconds.  The two time
  193.      periods thus specified are added together, and
  194.      `accept-process-output' returns after that much time whether or
  195.      not there has been any subprocess output.  Note that SECONDS is
  196.      allowed to be a floating-point number; thus, there is no need to
  197.      ever use MILLISEC. (It is retained for compatibility purposes.)
  198.  
  199.      The function `accept-process-output' returns non-`nil' if it did
  200.      get some output, or `nil' if the timeout expired before output
  201.      arrived.
  202.  
  203. 
  204. File: lispref.info,  Node: Sentinels,  Next: Process Window Size,  Prev: Output from Processes,  Up: Processes
  205.  
  206. Sentinels: Detecting Process Status Changes
  207. ===========================================
  208.  
  209.    A "process sentinel" is a function that is called whenever the
  210. associated process changes status for any reason, including signals
  211. (whether sent by XEmacs or caused by the process's own actions) that
  212. terminate, stop, or continue the process.  The process sentinel is also
  213. called if the process exits.  The sentinel receives two arguments: the
  214. process for which the event occurred, and a string describing the type
  215. of event.
  216.  
  217.    The string describing the event looks like one of the following:
  218.  
  219.    * `"finished\n"'.
  220.  
  221.    * `"exited abnormally with code EXITCODE\n"'.
  222.  
  223.    * `"NAME-OF-SIGNAL\n"'.
  224.  
  225.    * `"NAME-OF-SIGNAL (core dumped)\n"'.
  226.  
  227.    A sentinel runs only while XEmacs is waiting (e.g., for terminal
  228. input, or for time to elapse, or for process output).  This avoids the
  229. timing errors that could result from running them at random places in
  230. the middle of other Lisp programs.  A program can wait, so that
  231. sentinels will run, by calling `sit-for' or `sleep-for' (*note
  232. Waiting::.), or `accept-process-output' (*note Accepting Output::.).
  233. Emacs is also waiting when the command loop is reading input.
  234.  
  235.    Quitting is normally inhibited within a sentinel--otherwise, the
  236. effect of typing `C-g' at command level or to quit a user command would
  237. be unpredictable.  If you want to permit quitting inside a sentinel,
  238. bind `inhibit-quit' to `nil'.  *Note Quitting::.
  239.  
  240.    A sentinel that writes the output into the buffer of the process
  241. should check whether the buffer is still alive.  If it tries to insert
  242. into a dead buffer, it will get an error.  If the buffer is dead,
  243. `(buffer-name (process-buffer PROCESS))' returns `nil'.
  244.  
  245.    If an error happens during execution of a sentinel, it is caught
  246. automatically, so that it doesn't stop the execution of whatever
  247. programs was running when the sentinel was started.  However, if
  248. `debug-on-error' is non-`nil', the error-catching is turned off.  This
  249. makes it possible to use the Lisp debugger to debug the sentinel.
  250. *Note Debugger::.
  251.  
  252.    In earlier Emacs versions, every sentinel that did regexp searching
  253. or matching had to explicitly save and restore the match data.  Now
  254. Emacs does this automatically; sentinels never need to do it explicitly.
  255. *Note Match Data::.
  256.  
  257.  - Function: set-process-sentinel PROCESS SENTINEL
  258.      This function associates SENTINEL with PROCESS.  If SENTINEL is
  259.      `nil', then the process will have no sentinel.  The default
  260.      behavior when there is no sentinel is to insert a message in the
  261.      process's buffer when the process status changes.
  262.  
  263.           (defun msg-me (process event)
  264.              (princ
  265.                (format "Process: %s had the event `%s'" process event)))
  266.           (set-process-sentinel (get-process "shell") 'msg-me)
  267.                => msg-me
  268.  
  269.           (kill-process (get-process "shell"))
  270.                -| Process: #<process shell> had the event `killed'
  271.                => #<process shell>
  272.  
  273.  - Function: process-sentinel PROCESS
  274.      This function returns the sentinel of PROCESS, or `nil' if it has
  275.      none.
  276.  
  277.  - Function: waiting-for-user-input-p
  278.      While a sentinel or filter function is running, this function
  279.      returns non-`nil' if XEmacs was waiting for keyboard input from
  280.      the user at the time the sentinel or filter function was called,
  281.      `nil' if it was not.
  282.  
  283. 
  284. File: lispref.info,  Node: Process Window Size,  Next: Transaction Queues,  Prev: Sentinels,  Up: Processes
  285.  
  286. Process Window Size
  287. ===================
  288.  
  289.  - Function: set-process-window-size PROCESS HEIGHT WIDTH
  290.      This function tells PROCESS that its logical window size is HEIGHT
  291.      by WIDTH characters.  This is principally useful with pty's.
  292.  
  293. 
  294. File: lispref.info,  Node: Transaction Queues,  Next: Network,  Prev: Process Window Size,  Up: Processes
  295.  
  296. Transaction Queues
  297. ==================
  298.  
  299.    You can use a "transaction queue" for more convenient communication
  300. with subprocesses using transactions.  First use `tq-create' to create
  301. a transaction queue communicating with a specified process.  Then you
  302. can call `tq-enqueue' to send a transaction.
  303.  
  304.  - Function: tq-create PROCESS
  305.      This function creates and returns a transaction queue
  306.      communicating with PROCESS.  The argument PROCESS should be a
  307.      subprocess capable of sending and receiving streams of bytes.  It
  308.      may be a child process, or it may be a TCP connection to a server,
  309.      possibly on another machine.
  310.  
  311.  - Function: tq-enqueue QUEUE QUESTION REGEXP CLOSURE FN
  312.      This function sends a transaction to queue QUEUE.  Specifying the
  313.      queue has the effect of specifying the subprocess to talk to.
  314.  
  315.      The argument QUESTION is the outgoing message that starts the
  316.      transaction.  The argument FN is the function to call when the
  317.      corresponding answer comes back; it is called with two arguments:
  318.      CLOSURE, and the answer received.
  319.  
  320.      The argument REGEXP is a regular expression that should match the
  321.      entire answer, but nothing less; that's how `tq-enqueue' determines
  322.      where the answer ends.
  323.  
  324.      The return value of `tq-enqueue' itself is not meaningful.
  325.  
  326.  - Function: tq-close QUEUE
  327.      Shut down transaction queue QUEUE, waiting for all pending
  328.      transactions to complete, and then terminate the connection or
  329.      child process.
  330.  
  331.    Transaction queues are implemented by means of a filter function.
  332. *Note Filter Functions::.
  333.  
  334. 
  335. File: lispref.info,  Node: Network,  Prev: Transaction Queues,  Up: Processes
  336.  
  337. Network Connections
  338. ===================
  339.  
  340.    Emacs Lisp programs can open TCP network connections to other
  341. processes on the same machine or other machines.  A network connection
  342. is handled by Lisp much like a subprocess, and is represented by a
  343. process object.  However, the process you are communicating with is not
  344. a child of the XEmacs process, so you can't kill it or send it signals.
  345. All you can do is send and receive data.  `delete-process' closes the
  346. connection, but does not kill the process at the other end; that
  347. process must decide what to do about closure of the connection.
  348.  
  349.    You can distinguish process objects representing network connections
  350. from those representing subprocesses with the `process-status'
  351. function.  It always returns either `open' or `closed' for a network
  352. connection, and it never returns either of those values for a real
  353. subprocess.  *Note Process Information::.
  354.  
  355.  - Function: open-network-stream NAME BUFFER-OR-NAME HOST SERVICE
  356.      This function opens a TCP connection for a service to a host.  It
  357.      returns a process object to represent the connection.
  358.  
  359.      The NAME argument specifies the name for the process object.  It
  360.      is modified as necessary to make it unique.
  361.  
  362.      The BUFFER-OR-NAME argument is the buffer to associate with the
  363.      connection.  Output from the connection is inserted in the buffer,
  364.      unless you specify a filter function to handle the output.  If
  365.      BUFFER-OR-NAME is `nil', it means that the connection is not
  366.      associated with any buffer.
  367.  
  368.      The arguments HOST and SERVICE specify where to connect to; HOST
  369.      is the host name or IP address (a string), and SERVICE is the name
  370.      of a defined network service (a string) or a port number (an
  371.      integer).
  372.  
  373. 
  374. File: lispref.info,  Node: System Interface,  Next: X-Windows,  Prev: Processes,  Up: Top
  375.  
  376. Operating System Interface
  377. **************************
  378.  
  379.    This chapter is about starting and getting out of Emacs, access to
  380. values in the operating system environment, and terminal input, output,
  381. and flow control.
  382.  
  383.    *Note Building XEmacs::, for related information.  See also *Note
  384. Display::, for additional operating system status information
  385. pertaining to the terminal and the screen.
  386.  
  387. * Menu:
  388.  
  389. * Starting Up::         Customizing XEmacs start-up processing.
  390. * Getting Out::         How exiting works (permanent or temporary).
  391. * System Environment::  Distinguish the name and kind of system.
  392. * User Identification:: Finding the name and user id of the user.
  393. * Time of Day::        Getting the current time.
  394. * Time Conversion::     Converting a time from numeric form to a string, or
  395.                           to calendrical data (or vice versa).
  396. * Timers::        Setting a timer to call a function at a certain time.
  397. * Terminal Input::      Recording terminal input for debugging.
  398. * Terminal Output::     Recording terminal output for debugging.
  399. * Flow Control::        How to turn output flow control on or off.
  400. * Batch Mode::          Running XEmacs without terminal interaction.
  401.  
  402. 
  403. File: lispref.info,  Node: Starting Up,  Next: Getting Out,  Up: System Interface
  404.  
  405. Starting Up XEmacs
  406. ==================
  407.  
  408.    This section describes what XEmacs does when it is started, and how
  409. you can customize these actions.
  410.  
  411. * Menu:
  412.  
  413. * Start-up Summary::        Sequence of actions XEmacs performs at start-up.
  414. * Init File::               Details on reading the init file (`.emacs').
  415. * Terminal-Specific::       How the terminal-specific Lisp file is read.
  416. * Command Line Arguments::  How command line arguments are processed,
  417.                               and how you can customize them.
  418.  
  419. 
  420. File: lispref.info,  Node: Start-up Summary,  Next: Init File,  Up: Starting Up
  421.  
  422. Summary: Sequence of Actions at Start Up
  423. ----------------------------------------
  424.  
  425.    The order of operations performed (in `startup.el') by XEmacs when
  426. it is started up is as follows:
  427.  
  428.   1. It loads the initialization library for the window system, if you
  429.      are using a window system.  This library's name is
  430.      `term/WINDOWSYSTEM-win.el'.
  431.  
  432.   2. It processes the initial options.  (Some of them are handled even
  433.      earlier than this.)
  434.  
  435.   3. It initializes the X window frame and faces, if appropriate.
  436.  
  437.   4. It runs the normal hook `before-init-hook'.
  438.  
  439.   5. It loads the library `site-start', unless the option
  440.      `-no-site-file' was specified.  The library's file name is usually
  441.      `site-start.el'.
  442.  
  443.   6. It loads the file `~/.emacs' unless `-q' was specified on the
  444.      command line.  (This is not done in `-batch' mode.)  The `-u'
  445.      option can specify the user name whose home directory should be
  446.      used instead of `~'.
  447.  
  448.   7. It loads the library `default' unless `inhibit-default-init' is
  449.      non-`nil'.  (This is not done in `-batch' mode or if `-q' was
  450.      specified on the command line.)  The library's file name is
  451.      usually `default.el'.
  452.  
  453.   8. It runs the normal hook `after-init-hook'.
  454.  
  455.   9. It sets the major mode according to `initial-major-mode', provided
  456.      the buffer `*scratch*' is still current and still in Fundamental
  457.      mode.
  458.  
  459.  10. It loads the terminal-specific Lisp file, if any, except when in
  460.      batch mode or using a window system.
  461.  
  462.  11. It displays the initial echo area message, unless you have
  463.      suppressed that with `inhibit-startup-echo-area-message'.
  464.  
  465.  12. It processes the action arguments from the command line.
  466.  
  467.  13. It runs `term-setup-hook'.
  468.  
  469.  14. It calls `frame-notice-user-settings', which modifies the
  470.      parameters of the selected frame according to whatever the init
  471.      files specify.
  472.  
  473.  15. It runs `window-setup-hook'.  *Note Terminal-Specific::.
  474.  
  475.  16. It displays copyleft, nonwarranty, and basic use information,
  476.      provided there were no remaining command line arguments (a few
  477.      steps above) and the value of `inhibit-startup-message' is `nil'.
  478.  
  479.  - User Option: inhibit-startup-message
  480.      This variable inhibits the initial startup messages (the
  481.      nonwarranty, etc.).  If it is non-`nil', then the messages are not
  482.      printed.
  483.  
  484.      This variable exists so you can set it in your personal init file,
  485.      once you are familiar with the contents of the startup message.
  486.      Do not set this variable in the init file of a new user, or in a
  487.      way that affects more than one user, because that would prevent
  488.      new users from receiving the information they are supposed to see.
  489.  
  490.  - User Option: inhibit-startup-echo-area-message
  491.      This variable controls the display of the startup echo area
  492.      message.  You can suppress the startup echo area message by adding
  493.      text with this form to your `.emacs' file:
  494.  
  495.           (setq inhibit-startup-echo-area-message
  496.                 "YOUR-LOGIN-NAME")
  497.  
  498.      Simply setting `inhibit-startup-echo-area-message' to your login
  499.      name is not sufficient to inhibit the message; Emacs explicitly
  500.      checks whether `.emacs' contains an expression as shown above.
  501.      Your login name must appear in the expression as a Lisp string
  502.      constant.
  503.  
  504.      This way, you can easily inhibit the message for yourself if you
  505.      wish, but thoughtless copying of your `.emacs' file will not
  506.      inhibit the message for someone else.
  507.  
  508. 
  509. File: lispref.info,  Node: Init File,  Next: Terminal-Specific,  Prev: Start-up Summary,  Up: Starting Up
  510.  
  511. The Init File: `.emacs'
  512. -----------------------
  513.  
  514.    When you start XEmacs, it normally attempts to load the file
  515. `.emacs' from your home directory.  This file, if it exists, must
  516. contain Lisp code.  It is called your "init file".  The command line
  517. switches `-q' and `-u' affect the use of the init file; `-q' says not
  518. to load an init file, and `-u' says to load a specified user's init
  519. file instead of yours.  *Note Entering XEmacs: (emacs)Entering XEmacs.
  520.  
  521.    A site may have a "default init file", which is the library named
  522. `default.el'.  XEmacs finds the `default.el' file through the standard
  523. search path for libraries (*note How Programs Do Loading::.).  The
  524. XEmacs distribution does not come with this file; sites may provide one
  525. for local customizations.  If the default init file exists, it is
  526. loaded whenever you start Emacs, except in batch mode or if `-q' is
  527. specified.  But your own personal init file, if any, is loaded first; if
  528. it sets `inhibit-default-init' to a non-`nil' value, then XEmacs does
  529. not subsequently load the `default.el' file.
  530.  
  531.    Another file for site-customization is `site-start.el'.  Emacs loads
  532. this *before* the user's init file.  You can inhibit the loading of
  533. this file with the option `-no-site-file'.
  534.  
  535.  - Variable: site-run-file
  536.      This variable specifies the site-customization file to load before
  537.      the user's init file.  Its normal value is `"site-start"'.
  538.  
  539.    If there is a great deal of code in your `.emacs' file, you should
  540. move it into another file named `SOMETHING.el', byte-compile it (*note
  541. Byte Compilation::.), and make your `.emacs' file load the other file
  542. using `load' (*note Loading::.).
  543.  
  544.    *Note Init File Examples: (emacs)Init File Examples, for examples of
  545. how to make various commonly desired customizations in your `.emacs'
  546. file.
  547.  
  548.  - User Option: inhibit-default-init
  549.      This variable prevents XEmacs from loading the default
  550.      initialization library file for your session of XEmacs.  If its
  551.      value is non-`nil', then the default library is not loaded.  The
  552.      default value is `nil'.
  553.  
  554.  - Variable: before-init-hook
  555.  - Variable: after-init-hook
  556.      These two normal hooks are run just before, and just after,
  557.      loading of the user's init file, `default.el', and/or
  558.      `site-start.el'.
  559.  
  560. 
  561. File: lispref.info,  Node: Terminal-Specific,  Next: Command Line Arguments,  Prev: Init File,  Up: Starting Up
  562.  
  563. Terminal-Specific Initialization
  564. --------------------------------
  565.  
  566.    Each terminal type can have its own Lisp library that XEmacs loads
  567. when run on that type of terminal.  For a terminal type named TERMTYPE,
  568. the library is called `term/TERMTYPE'.  XEmacs finds the file by
  569. searching the `load-path' directories as it does for other files, and
  570. trying the `.elc' and `.el' suffixes.  Normally, terminal-specific Lisp
  571. library is located in `emacs/lisp/term', a subdirectory of the
  572. `emacs/lisp' directory in which most Emacs Lisp libraries are kept.
  573.  
  574.    The library's name is constructed by concatenating the value of the
  575. variable `term-file-prefix' and the terminal type.  Normally,
  576. `term-file-prefix' has the value `"term/"'; changing this is not
  577. recommended.
  578.  
  579.    The usual function of a terminal-specific library is to enable
  580. special keys to send sequences that XEmacs can recognize.  It may also
  581. need to set or add to `function-key-map' if the Termcap entry does not
  582. specify all the terminal's function keys.  *Note Terminal Input::.
  583.  
  584.    When the name of the terminal type contains a hyphen, only the part
  585. of the name before the first hyphen is significant in choosing the
  586. library name.  Thus, terminal types `aaa-48' and `aaa-30-rv' both use
  587. the `term/aaa' library.  If necessary, the library can evaluate
  588. `(getenv "TERM")' to find the full name of the terminal type.
  589.  
  590.    Your `.emacs' file can prevent the loading of the terminal-specific
  591. library by setting the variable `term-file-prefix' to `nil'.  This
  592. feature is useful when experimenting with your own peculiar
  593. customizations.
  594.  
  595.    You can also arrange to override some of the actions of the
  596. terminal-specific library by setting the variable `term-setup-hook'.
  597. This is a normal hook which XEmacs runs using `run-hooks' at the end of
  598. XEmacs initialization, after loading both your `.emacs' file and any
  599. terminal-specific libraries.  You can use this variable to define
  600. initializations for terminals that do not have their own libraries.
  601. *Note Hooks::.
  602.  
  603.  - Variable: term-file-prefix
  604.      If the `term-file-prefix' variable is non-`nil', XEmacs loads a
  605.      terminal-specific initialization file as follows:
  606.  
  607.           (load (concat term-file-prefix (getenv "TERM")))
  608.  
  609.      You may set the `term-file-prefix' variable to `nil' in your
  610.      `.emacs' file if you do not wish to load the
  611.      terminal-initialization file.  To do this, put the following in
  612.      your `.emacs' file: `(setq term-file-prefix nil)'.
  613.  
  614.  - Variable: term-setup-hook
  615.      This variable is a normal hook that XEmacs runs after loading your
  616.      `.emacs' file, the default initialization file (if any) and the
  617.      terminal-specific Lisp file.
  618.  
  619.      You can use `term-setup-hook' to override the definitions made by a
  620.      terminal-specific file.
  621.  
  622.  - Variable: window-setup-hook
  623.      This variable is a normal hook which XEmacs runs after loading your
  624.      `.emacs' file and the default initialization file (if any), after
  625.      loading terminal-specific Lisp code, and after running the hook
  626.      `term-setup-hook'.
  627.  
  628. 
  629. File: lispref.info,  Node: Command Line Arguments,  Prev: Terminal-Specific,  Up: Starting Up
  630.  
  631. Command Line Arguments
  632. ----------------------
  633.  
  634.    You can use command line arguments to request various actions when
  635. you start XEmacs.  Since you do not need to start XEmacs more than once
  636. per day, and will often leave your XEmacs session running longer than
  637. that, command line arguments are hardly ever used.  As a practical
  638. matter, it is best to avoid making the habit of using them, since this
  639. habit would encourage you to kill and restart XEmacs unnecessarily
  640. often.  These options exist for two reasons: to be compatible with
  641. other editors (for invocation by other programs) and to enable shell
  642. scripts to run specific Lisp programs.
  643.  
  644.    This section describes how Emacs processes command line arguments,
  645. and how you can customize them.
  646.  
  647.  - Function: command-line
  648.      This function parses the command line that XEmacs was called with,
  649.      processes it, loads the user's `.emacs' file and displays the
  650.      startup messages.
  651.  
  652.  - Variable: command-line-processed
  653.      The value of this variable is `t' once the command line has been
  654.      processed.
  655.  
  656.      If you redump XEmacs by calling `dump-emacs', you may wish to set
  657.      this variable to `nil' first in order to cause the new dumped
  658.      XEmacs to process its new command line arguments.
  659.  
  660.  - Variable: command-switch-alist
  661.      The value of this variable is an alist of user-defined command-line
  662.      options and associated handler functions.  This variable exists so
  663.      you can add elements to it.
  664.  
  665.      A "command line option" is an argument on the command line of the
  666.      form:
  667.  
  668.           -OPTION
  669.  
  670.      The elements of the `command-switch-alist' look like this:
  671.  
  672.           (OPTION . HANDLER-FUNCTION)
  673.  
  674.      The HANDLER-FUNCTION is called to handle OPTION and receives the
  675.      option name as its sole argument.
  676.  
  677.      In some cases, the option is followed in the command line by an
  678.      argument.  In these cases, the HANDLER-FUNCTION can find all the
  679.      remaining command-line arguments in the variable
  680.      `command-line-args-left'.  (The entire list of command-line
  681.      arguments is in `command-line-args'.)
  682.  
  683.      The command line arguments are parsed by the `command-line-1'
  684.      function in the `startup.el' file.  See also *Note Command Line
  685.      Switches and Arguments: (emacs)Command Switches.
  686.  
  687.  - Variable: command-line-args
  688.      The value of this variable is the list of command line arguments
  689.      passed to XEmacs.
  690.  
  691.  - Variable: command-line-functions
  692.      This variable's value is a list of functions for handling an
  693.      unrecognized command-line argument.  Each time the next argument
  694.      to be processed has no special meaning, the functions in this list
  695.      are called, in order of appearance, until one of them returns a
  696.      non-`nil' value.
  697.  
  698.      These functions are called with no arguments.  They can access the
  699.      command-line argument under consideration through the variable
  700.      `argi'.  The remaining arguments (not including the current one)
  701.      are in the variable `command-line-args-left'.
  702.  
  703.      When a function recognizes and processes the argument in `argi', it
  704.      should return a non-`nil' value to say it has dealt with that
  705.      argument.  If it has also dealt with some of the following
  706.      arguments, it can indicate that by deleting them from
  707.      `command-line-args-left'.
  708.  
  709.      If all of these functions return `nil', then the argument is used
  710.      as a file name to visit.
  711.  
  712. 
  713. File: lispref.info,  Node: Getting Out,  Next: System Environment,  Prev: Starting Up,  Up: System Interface
  714.  
  715. Getting out of XEmacs
  716. =====================
  717.  
  718.    There are two ways to get out of XEmacs: you can kill the XEmacs job,
  719. which exits permanently, or you can suspend it, which permits you to
  720. reenter the XEmacs process later.  As a practical matter, you seldom
  721. kill XEmacs--only when you are about to log out.  Suspending is much
  722. more common.
  723.  
  724. * Menu:
  725.  
  726. * Killing XEmacs::        Exiting XEmacs irreversibly.
  727. * Suspending XEmacs::     Exiting XEmacs reversibly.
  728.  
  729. 
  730. File: lispref.info,  Node: Killing XEmacs,  Next: Suspending XEmacs,  Up: Getting Out
  731.  
  732. Killing XEmacs
  733. --------------
  734.  
  735.    Killing XEmacs means ending the execution of the XEmacs process.  The
  736. parent process normally resumes control.  The low-level primitive for
  737. killing XEmacs is `kill-emacs'.
  738.  
  739.  - Function: kill-emacs &optional EXIT-DATA
  740.      This function exits the XEmacs process and kills it.
  741.  
  742.      If EXIT-DATA is an integer, then it is used as the exit status of
  743.      the XEmacs process.  (This is useful primarily in batch operation;
  744.      see *Note Batch Mode::.)
  745.  
  746.      If EXIT-DATA is a string, its contents are stuffed into the
  747.      terminal input buffer so that the shell (or whatever program next
  748.      reads input) can read them.
  749.  
  750.    All the information in the XEmacs process, aside from files that have
  751. been saved, is lost when the XEmacs is killed.  Because killing XEmacs
  752. inadvertently can lose a lot of work, XEmacs queries for confirmation
  753. before actually terminating if you have buffers that need saving or
  754. subprocesses that are running.  This is done in the function
  755. `save-buffers-kill-emacs'.
  756.  
  757.  - Variable: kill-emacs-query-functions
  758.      After asking the standard questions, `save-buffers-kill-emacs'
  759.      calls the functions in the list `kill-buffer-query-functions', in
  760.      order of appearance, with no arguments.  These functions can ask
  761.      for additional confirmation from the user.  If any of them returns
  762.      non-`nil', XEmacs is not killed.
  763.  
  764.  - Variable: kill-emacs-hook
  765.      This variable is a normal hook; once `save-buffers-kill-emacs' is
  766.      finished with all file saving and confirmation, it runs the
  767.      functions in this hook.
  768.  
  769. 
  770. File: lispref.info,  Node: Suspending XEmacs,  Prev: Killing XEmacs,  Up: Getting Out
  771.  
  772. Suspending XEmacs
  773. -----------------
  774.  
  775.    "Suspending XEmacs" means stopping XEmacs temporarily and returning
  776. control to its superior process, which is usually the shell.  This
  777. allows you to resume editing later in the same XEmacs process, with the
  778. same buffers, the same kill ring, the same undo history, and so on.  To
  779. resume XEmacs, use the appropriate command in the parent shell--most
  780. likely `fg'.
  781.  
  782.    Some operating systems do not support suspension of jobs; on these
  783. systems, "suspension" actually creates a new shell temporarily as a
  784. subprocess of XEmacs.  Then you would exit the shell to return to
  785. XEmacs.
  786.  
  787.    Suspension is not useful with window systems such as X, because the
  788. XEmacs job may not have a parent that can resume it again, and in any
  789. case you can give input to some other job such as a shell merely by
  790. moving to a different window.  Therefore, suspending is not allowed
  791. when XEmacs is an X client.
  792.  
  793.  - Function: suspend-emacs STRING
  794.      This function stops XEmacs and returns control to the superior
  795.      process.  If and when the superior process resumes XEmacs,
  796.      `suspend-emacs' returns `nil' to its caller in Lisp.
  797.  
  798.      If STRING is non-`nil', its characters are sent to be read as
  799.      terminal input by XEmacs's superior shell.  The characters in
  800.      STRING are not echoed by the superior shell; only the results
  801.      appear.
  802.  
  803.      Before suspending, `suspend-emacs' runs the normal hook
  804.      `suspend-hook'.  In Emacs version 18, `suspend-hook' was not a
  805.      normal hook; its value was a single function, and if its value was
  806.      non-`nil', then `suspend-emacs' returned immediately without
  807.      actually suspending anything.
  808.  
  809.      After the user resumes XEmacs, `suspend-emacs' runs the normal hook
  810.      `suspend-resume-hook'.  *Note Hooks::.
  811.  
  812.      The next redisplay after resumption will redraw the entire screen,
  813.      unless the variable `no-redraw-on-reenter' is non-`nil' (*note
  814.      Refresh Screen::.).
  815.  
  816.      In the following example, note that `pwd' is not echoed after
  817.      XEmacs is suspended.  But it is read and executed by the shell.
  818.  
  819.           (suspend-emacs)
  820.                => nil
  821.  
  822.           (add-hook 'suspend-hook
  823.                     (function (lambda ()
  824.                                 (or (y-or-n-p
  825.                                       "Really suspend? ")
  826.                                     (error "Suspend cancelled")))))
  827.                => (lambda nil
  828.                     (or (y-or-n-p "Really suspend? ")
  829.                         (error "Suspend cancelled")))
  830.  
  831.           (add-hook 'suspend-resume-hook
  832.                     (function (lambda () (message "Resumed!"))))
  833.                => (lambda nil (message "Resumed!"))
  834.  
  835.           (suspend-emacs "pwd")
  836.                => nil
  837.  
  838.           ---------- Buffer: Minibuffer ----------
  839.           Really suspend? `y'
  840.           ---------- Buffer: Minibuffer ----------
  841.  
  842.           ---------- Parent Shell ----------
  843.           lewis@slug[23] % /user/lewis/manual
  844.           lewis@slug[24] % fg
  845.  
  846.           ---------- Echo Area ----------
  847.           Resumed!
  848.  
  849.  - Variable: suspend-hook
  850.      This variable is a normal hook run before suspending.
  851.  
  852.  - Variable: suspend-resume-hook
  853.      This variable is a normal hook run after suspending.
  854.  
  855. 
  856. File: lispref.info,  Node: System Environment,  Next: User Identification,  Prev: Getting Out,  Up: System Interface
  857.  
  858. Operating System Environment
  859. ============================
  860.  
  861.    XEmacs provides access to variables in the operating system
  862. environment through various functions.  These variables include the
  863. name of the system, the user's UID, and so on.
  864.  
  865.  - Variable: system-type
  866.      The value of this variable is a symbol indicating the type of
  867.      operating system XEmacs is operating on.  Here is a table of the
  868.      possible values:
  869.  
  870.     `aix-v3'
  871.           AIX.
  872.  
  873.     `berkeley-unix'
  874.           Berkeley BSD.
  875.  
  876.     `dgux'
  877.           Data General DGUX operating system.
  878.  
  879.     `gnu'
  880.           A GNU system using the GNU HURD and Mach.
  881.  
  882.     `hpux'
  883.           Hewlett-Packard HPUX operating system.
  884.  
  885.     `irix'
  886.           Silicon Graphics Irix system.
  887.  
  888.     `linux'
  889.           A GNU system using the Linux kernel.
  890.  
  891.     `ms-dos'
  892.           Microsoft MS-DOS "operating system."
  893.  
  894.     `next-mach'
  895.           NeXT Mach-based system.
  896.  
  897.     `rtu'
  898.           Masscomp RTU, UCB universe.
  899.  
  900.     `unisoft-unix'
  901.           UniSoft UniPlus.
  902.  
  903.     `usg-unix-v'
  904.           AT&T System V.
  905.  
  906.     `vax-vms'
  907.           VAX VMS.
  908.  
  909.     `windows-nt'
  910.           Microsoft windows NT.
  911.  
  912.     `xenix'
  913.           SCO Xenix 386.
  914.  
  915.      We do not wish to add new symbols to make finer distinctions
  916.      unless it is absolutely necessary!  In fact, we hope to eliminate
  917.      some of these alternatives in the future.  We recommend using
  918.      `system-configuration' to distinguish between different operating
  919.      systems.
  920.  
  921.  - Variable: system-configuration
  922.      This variable holds the three-part configuration name for the
  923.      hardware/software configuration of your system, as a string.  The
  924.      convenient way to test parts of this string is with `string-match'.
  925.  
  926.  - Function: system-name
  927.      This function returns the name of the machine you are running on.
  928.           (system-name)
  929.                => "prep.ai.mit.edu"
  930.  
  931.    The symbol `system-name' is a variable as well as a function.  In
  932. fact, the function returns whatever value the variable `system-name'
  933. currently holds.  Thus, you can set the variable `system-name' in case
  934. Emacs is confused about the name of your system.  The variable is also
  935. useful for constructing frame titles (*note Frame Titles::.).
  936.  
  937.  - Variable: mail-host-address
  938.      If this variable is non-`nil', it is used instead of `system-name'
  939.      for purposes of generating email addresses.  For example, it is
  940.      used when constructing the default value of `user-mail-address'.
  941.      *Note User Identification::.  (Since this is done when XEmacs
  942.      starts up, the value actually used is the one saved when XEmacs
  943.      was dumped.  *Note Building XEmacs::.)
  944.  
  945.  - Function: getenv VAR
  946.      This function returns the value of the environment variable VAR,
  947.      as a string.  Within XEmacs, the environment variable values are
  948.      kept in the Lisp variable `process-environment'.
  949.  
  950.           (getenv "USER")
  951.                => "lewis"
  952.           
  953.           lewis@slug[10] % printenv
  954.           PATH=.:/user/lewis/bin:/usr/bin:/usr/local/bin
  955.           USER=lewis
  956.           TERM=ibmapa16
  957.           SHELL=/bin/csh
  958.           HOME=/user/lewis
  959.  
  960.  - Command: setenv VARIABLE VALUE
  961.      This command sets the value of the environment variable named
  962.      VARIABLE to VALUE.  Both arguments should be strings.  This
  963.      function works by modifying `process-environment'; binding that
  964.      variable with `let' is also reasonable practice.
  965.  
  966.  - Variable: process-environment
  967.      This variable is a list of strings, each describing one environment
  968.      variable.  The functions `getenv' and `setenv' work by means of
  969.      this variable.
  970.  
  971.           process-environment
  972.           => ("l=/usr/stanford/lib/gnuemacs/lisp"
  973.               "PATH=.:/user/lewis/bin:/usr/class:/nfsusr/local/bin"
  974.               "USER=lewis"
  975.  
  976.           "TERM=ibmapa16"
  977.               "SHELL=/bin/csh"
  978.               "HOME=/user/lewis")
  979.  
  980.  - Variable: path-separator
  981.      This variable holds a string which says which character separates
  982.      directories in a search path (as found in an environment
  983.      variable).  Its value is `":"' for Unix and GNU systems, and `";"'
  984.      for MS-DOS and Windows NT.
  985.  
  986.  - Variable: invocation-name
  987.      This variable holds the program name under which Emacs was
  988.      invoked.  The value is a string, and does not include a directory
  989.      name.
  990.  
  991.  - Variable: invocation-directory
  992.      This variable holds the directory from which the Emacs executable
  993.      was invoked, or perhaps `nil' if that directory cannot be
  994.      determined.
  995.  
  996.  - Variable: installation-directory
  997.      If non-`nil', this is a directory within which to look for the
  998.      `lib-src' and `etc' subdirectories.  This is non-`nil' when Emacs
  999.      can't find those directories in their standard installed
  1000.      locations, but can find them in a directory related somehow to the
  1001.      one containing the Emacs executable.
  1002.  
  1003.  - Function: load-average
  1004.      This function returns the current 1-minute, 5-minute and 15-minute
  1005.      load averages in a list.  The values are integers that are 100
  1006.      times the system load averages.  (The load averages indicate the
  1007.      number of processes trying to run.)
  1008.  
  1009.           (load-average)
  1010.                => (169 48 36)
  1011.           
  1012.           lewis@rocky[5] % uptime
  1013.            11:55am  up 1 day, 19:37,  3 users,
  1014.            load average: 1.69, 0.48, 0.36
  1015.  
  1016.  - Function: emacs-pid
  1017.      This function returns the process ID of the Emacs process.
  1018.  
  1019.  - Function: setprv PRIVILEGE-NAME &optional SETP GETPRV
  1020.      This function sets or resets a VMS privilege.  (It does not exist
  1021.      on Unix.)  The first arg is the privilege name, as a string.  The
  1022.      second argument, SETP, is `t' or `nil', indicating whether the
  1023.      privilege is to be turned on or off.  Its default is `nil'.  The
  1024.      function returns `t' if successful, `nil' otherwise.
  1025.  
  1026.      If the third argument, GETPRV, is non-`nil', `setprv' does not
  1027.      change the privilege, but returns `t' or `nil' indicating whether
  1028.      the privilege is currently enabled.
  1029.  
  1030. 
  1031. File: lispref.info,  Node: User Identification,  Next: Time of Day,  Prev: System Environment,  Up: System Interface
  1032.  
  1033. User Identification
  1034. ===================
  1035.  
  1036.  - Variable: user-mail-address
  1037.      This holds the nominal email address of the user who is using
  1038.      Emacs.  When Emacs starts up, it computes a default value that is
  1039.      usually right, but users often set this themselves when the
  1040.      default value is not right.
  1041.  
  1042.  - Function: user-login-name &optional UID
  1043.      If you don't specify UID, this function returns the name under
  1044.      which the user is logged in.  If the environment variable `LOGNAME'
  1045.      is set, that value is used.  Otherwise, if the environment variable
  1046.      `USER' is set, that value is used.  Otherwise, the value is based
  1047.      on the effective UID, not the real UID.
  1048.  
  1049.      If you specify UID, the value is the user name that corresponds to
  1050.      UID (which should be an integer).
  1051.  
  1052.           (user-login-name)
  1053.                => "lewis"
  1054.  
  1055.  - Function: user-real-login-name
  1056.      This function returns the user name corresponding to Emacs's real
  1057.      UID.  This ignores the effective UID and ignores the environment
  1058.      variables `LOGNAME' and `USER'.
  1059.  
  1060.  - Function: user-full-name
  1061.      This function returns the full name of the user.
  1062.  
  1063.           (user-full-name)
  1064.                => "Bil Lewis"
  1065.  
  1066.    The symbols `user-login-name', `user-real-login-name' and
  1067. `user-full-name' are variables as well as functions.  The functions
  1068. return the same values that the variables hold.  These variables allow
  1069. you to "fake out" Emacs by telling the functions what to return.  The
  1070. variables are also useful for constructing frame titles (*note Frame
  1071. Titles::.).
  1072.  
  1073.  - Function: user-real-uid
  1074.      This function returns the real UID of the user.
  1075.  
  1076.           (user-real-uid)
  1077.                => 19
  1078.  
  1079.  - Function: user-uid
  1080.      This function returns the effective UID of the user.
  1081.  
  1082. 
  1083. File: lispref.info,  Node: Time of Day,  Next: Time Conversion,  Prev: User Identification,  Up: System Interface
  1084.  
  1085. Time of Day
  1086. ===========
  1087.  
  1088.    This section explains how to determine the current time and the time
  1089. zone.
  1090.  
  1091.  - Function: current-time-string &optional TIME-VALUE
  1092.      This function returns the current time and date as a
  1093.      humanly-readable string.  The format of the string is unvarying;
  1094.      the number of characters used for each part is always the same, so
  1095.      you can reliably use `substring' to extract pieces of it.  It is
  1096.      wise to count the characters from the beginning of the string
  1097.      rather than from the end, as additional information may be added
  1098.      at the end.
  1099.  
  1100.      The argument TIME-VALUE, if given, specifies a time to format
  1101.      instead of the current time.  The argument should be a list whose
  1102.      first two elements are integers.  Thus, you can use times obtained
  1103.      from `current-time' (see below) and from `file-attributes' (*note
  1104.      File Attributes::.).
  1105.  
  1106.           (current-time-string)
  1107.                => "Wed Oct 14 22:21:05 1987"
  1108.  
  1109.  - Function: current-time
  1110.      This function returns the system's time value as a list of three
  1111.      integers: `(HIGH LOW MICROSEC)'.  The integers HIGH and LOW
  1112.      combine to give the number of seconds since 0:00 January 1, 1970,
  1113.      which is
  1114.  
  1115.      HIGH * 2**16 + LOW.
  1116.  
  1117.      The third element, MICROSEC, gives the microseconds since the
  1118.      start of the current second (or 0 for systems that return time
  1119.      only on the resolution of a second).
  1120.  
  1121.      The first two elements can be compared with file time values such
  1122.      as you get with the function `file-attributes'.  *Note File
  1123.      Attributes::.
  1124.  
  1125.  - Function: current-time-zone &optional TIME-VALUE
  1126.      This function returns a list describing the time zone that the
  1127.      user is in.
  1128.  
  1129.      The value has the form `(OFFSET NAME)'.  Here OFFSET is an integer
  1130.      giving the number of seconds ahead of UTC (east of Greenwich).  A
  1131.      negative value means west of Greenwich.  The second element, NAME
  1132.      is a string giving the name of the time zone.  Both elements
  1133.      change when daylight savings time begins or ends; if the user has
  1134.      specified a time zone that does not use a seasonal time
  1135.      adjustment, then the value is constant through time.
  1136.  
  1137.      If the operating system doesn't supply all the information
  1138.      necessary to compute the value, both elements of the list are
  1139.      `nil'.
  1140.  
  1141.      The argument TIME-VALUE, if given, specifies a time to analyze
  1142.      instead of the current time.  The argument should be a cons cell
  1143.      containing two integers, or a list whose first two elements are
  1144.      integers.  Thus, you can use times obtained from `current-time'
  1145.      (see above) and from `file-attributes' (*note File Attributes::.).
  1146.  
  1147.